﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DesignByContract.CodeContracts
{
    public class BeforeCodeContracts
    {
        public double ComputeInterest(double amount, double rate)
        {
            double result = 0;

            //Pre-Condition
            if (rate < 1)
                throw new ArgumentOutOfRangeException("Interest rate must be less than 1.");

            result = amount + amount * rate;

            //Post-Condition
            if (result < amount)
                throw new ArgumentOutOfRangeException("Amount after interest must be superior to initial amount.");

            return result;
        }
    }
}
